package angels.dao;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class FabricaEntityManager {

   private  static  EntityManagerFactory fabrica = Persistence.createEntityManagerFactory("app-angelsPU");

    public FabricaEntityManager() {
    }
    
    public static EntityManagerFactory obterFactory(){
        return fabrica;
    }
    public static EntityManagerFactory obterFactory(String unidadePersistencia){
        if (fabrica != null && fabrica.isOpen()) {
            fabrica.close();
        }
        fabrica = Persistence.createEntityManagerFactory(unidadePersistencia);
        return fabrica;
    }
}
